<?php if( $data['status'] == 200 ){ ?>
<script type="text/javascript">
    setTimeout(function(){
        jQuery(".chzn-select").chosen();
    },1);
</script>
	<p>
		<label>Mã coupon</label>
		<span class="field" style="padding-top: 5px;padding-top: 5px;position: relative;top: 4px;font-size: 20px;"><b><?php echo $data['data']->code_coupon;?></b></span>
	</p>
	<p>
		<label>Tên coupon</label>
		<span class="field" style="padding-top: 5px;"><?php echo $data['data']->title;?></span>
	</p>
	
	<p>
		<label>Số tiền giảm giá</label>
		<span class="field" style="padding-top: 5px;"><?php echo number_format($data['data']->sale_off);?> VNĐ</span>
	</p>
	<p>
		<label>Điều kiện</label>
		<span class="field" style="padding-top: 5px;"><?php echo $data['data']->condition;?></span>
	</p>
	<p>
		<label>Tên người nhận</label>
		<span class="field" style="padding-top: 5px;"><b><?php echo $data['data']->fullname ? $data['data']->fullname : "Đang cập nhật";?></b>   
		</span>
	</p>
	<p>
		<label>Tên tài khoản</label>
		<span class="field" style="padding-top: 5px;"><b><?php echo $data['data']->username;?></b> <?php if( $data['data']->user_active != 1 ){ ?> <b style="color: rgb(253, 47, 47);;">Tài khoản đang bị khóa</b> <?php } ?>
		</span>
	</p>
	<p>
		<label>Số điện thoại</label>
		<span class="field" style="padding-top: 5px;"><?php echo $data['data']->mobile ? $data['data']->mobile : "Đang cập nhật";?>
		</span>
	</p>
	<p>
		<label>Thời gian nhận</label>
		<span class="field" style="padding-top: 5px;"><?php echo date('H:i:s d-m-Y',strtotime($data['data']->created));?></span>
	</p>
	
	<?php if( $data['data']->active == 1 ){ ?>
		<input name="id" type="hidden" value="<?php echo $data['data']->id;?>" />
		<input name="code_coupon" type="hidden" value="<?php echo $data['data']->code_coupon;?>" />
		<input name="user_id" type="hidden" value="<?php echo $data['data']->user_id;?>" />
		<p>
			<label>Trạng thái</label>
			<span class="field" style="padding-top: 5px;font-weight: bold;color: rgb(25, 137, 25);">Chưa sử dụng</span>
		</p>
		<?php if( $data['data']->user_active == 1 ){ ?> 
		<p>
        	<label>Xác nhận đã sử dụng ( * )</label>
            <span class="field">
			<select name="active">
				<option value="2">Đã sử dụng</option>
			</select>
            </span>
        </p>
		<?php } ?>
		<p>
			<label></label>
			<?php if( $data['data']->user_active == 1 ){ ?> <button class="btn btn-rounded" type="submit"> <i class="iconfa-ok"></i> &nbsp; Lưu</button> <?php } ?>
			<button class="btn btn-rounded" type="button" onclick="window.location='<?php echo $baseurl.'manage/userecoupon/add-user-ecoupon'?>'"> <i class="icon-arrow-right"></i> &nbsp; Quay lại</button>
		</p>
	<?php }else{
		if( $data['data']->active == 2 ){
	?>
		<p>
			<label>Trạng thái</label>
			<span class="field" style="padding-top: 5px;font-weight: bold;color: rgb(42, 42, 255);">Đã sử dụng</span>
		</p>
		<p>
			<label>Thời gian sử dụng</label>
			<span class="field" style="padding-top: 5px;"><?php echo date('H:i:s d-m-Y',strtotime($data['data']->time_use));?></span>
		</p>
		<p>
		<label></label>
		<button class="btn btn-rounded" type="button" onclick="window.location='<?php echo $baseurl.'manage/userecoupon/add-user-ecoupon'?>'"> <i class="icon-arrow-right"></i> &nbsp; Quay lại</button>
	</p>
	<?php
		}
	} ?>
	
	<script>


$(function()
{   
    if($('#x2').is(':checked'))
    {
        $('#time_select_box').show();
    }else{
        $('#time_select_box').hide();
    }
    $('input[type=radio][name=incentives_type]').change(function()
    {
        var type = this.value;
        
        if(type == 1){
            $('#time_select_box').fadeIn('slow');    
        }else{
            $('#time_select_box').fadeOut('slow');
        }
    });
    if($('#r2').is(':checked'))
    {
        $('#restaurant_select_box').show();
    }else{
        $('#restaurant_select_box').hide();
    }
    $('input[type=radio][name=restaurant_target]').change(function()
    {
        var r_type = this.value;
        
        if(r_type == 1){
            $('#restaurant_select_box').fadeIn('slow');
        }else{
            $('#restaurant_select_box').fadeOut('slow');
        }
    });
});
</script>
<?php	
}else{
	 if( $data['status'] == 201 ){ ?>
	 	<input name="id" type="hidden" value="<?php echo $data['data']->id;?>" />
	<p>
		<label>Mã coupon</label>
		<span class="field" style="padding-top: 5px;padding-top: 5px;position: relative;top: 4px;font-size: 20px;"><b><?php echo $data['data']->code_coupon;?></b></span>
	</p>
	<p>
		<label>Tên coupon</label>
		<span class="field" style="padding-top: 5px;"><?php echo $data['data']->title;?></span>
	</p>
	
	<p>
		<label>Số tiền giảm giá</label>
		<span class="field" style="padding-top: 5px;"><?php echo number_format($data['data']->sale_off);?> VNĐ</span>
	</p>
	<p>
		<label>Điều kiện</label>
		<span class="field" style="padding-top: 5px;"><?php echo $data['data']->condition;?></span>
	</p>
	<p>
		<label>Trạng thái</label>
		<span class="field" style="color: rgb(253, 50, 50);position: relative;top: 5px;font-size: 14px;font-weight: bold;">Hiện tại chưa có ai nhận coupon này</span>
	</p>
	<p>
		<label></label>
		<button class="btn btn-rounded" type="button" onclick="window.location='<?php echo $baseurl.'manage/userecoupon/add-user-ecoupon'?>'"> <i class="icon-arrow-right"></i> &nbsp; Quay lại</button>
	</p>
	<script>


$(function()
{   
    if($('#x2').is(':checked'))
    {
        $('#time_select_box').show();
    }else{
        $('#time_select_box').hide();
    }
    $('input[type=radio][name=incentives_type]').change(function()
    {
        var type = this.value;
        
        if(type == 1){
            $('#time_select_box').fadeIn('slow');    
        }else{
            $('#time_select_box').fadeOut('slow');
        }
    });
    if($('#r2').is(':checked'))
    {
        $('#restaurant_select_box').show();
    }else{
        $('#restaurant_select_box').hide();
    }
    $('input[type=radio][name=restaurant_target]').change(function()
    {
        var r_type = this.value;
        
        if(r_type == 1){
            $('#restaurant_select_box').fadeIn('slow');
        }else{
            $('#restaurant_select_box').fadeOut('slow');
        }
    });
});
</script>
	 <?php
	}else{
			if( $data['status'] == 202 ){
				die('202');
			}else{
				die('404');
			}
		}
	}